<?php
 session_start();
 include("include/session.php");
 include("include/common.php");
 include("include/db.php");


  $sqlCourseData = mysql_query("SELECT sf.*,first_name,email 
  												FROM software_courses as sf 
													LEFT JOIN software_user AS SU ON SU.id = sf.trainer_id 
												WHERE sf.id = '".intval($_REQUEST['course_id'])."'");
  $resCourseData  = mysql_fetch_array($sqlCourseData);
  

 ?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?=TITLE_WEBSITE?></title>
<link href="css/c_energy.css" rel="stylesheet" type="text/css" />
<link href="css/logo.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="css/datepicker.css" type="text/css" />
<link rel="stylesheet" media="screen" type="text/css" href="css/layout.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/datepicker.js"></script>
<script type="text/javascript" src="js/eye.js"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript">
</script>
<style type="text/css">
<!--
.style4 {
	font-size: 22px;
	font-weight: bold;
}
.style6 {color: #999999}
-->
</style>
</head>
<body>

    <table width="990" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td colspan="3" align="left" valign="top" ><? require("header.php");?></td>
</tr>
  <tr>
    <td align="center" >
	<table width="99%" cellspacing="0" cellpadding="0">
      <tr>
        <td colspan="3" align="center" valign="top">&nbsp;</td>
      </tr>
       <tr bgcolor="#FAFAFA">
        <td colspan="0" align="left" valign="top" >
		   <table width="96%" cellspacing="0" cellpadding="0">
		    <tr>
		      <td width="2%" align="left" valign="top" style="padding-left:15px" ><? require("left.php");?></td>
		      <td width="94%"  valign="top" style="padding-left:15px" >
			  <form name="signform" action="" method="post" enctype="multipart/form-data" id="signform" onsubmit="return validation();" >
			    <table id="signInTbl" width="719" cellspacing="0" cellpadding="0" style="border:solid #cccccc 1px">
                  <tr>
                    <td colspan="2" align="left" bgcolor="#373737" class="loc_search_found_term"  style="border-bottom:solid #cccccc 1px">&nbsp;View Courses Detail </td>
                  </tr>
                  
                <tr height="30">
                    <td width="249" align="left" style="padding-left:15px"> Course</td>
                    <td width="466" align="left">
                        <select id="courses" name="courses" onchange="window.location.href='viewCourse.php?course_id='+this.value" >
                            <option value="" >Select</option>
                            <?php
                             $sqlCourses = mysql_query("SELECT name,batch_code,id FROM software_courses");
                             while($resCourses = mysql_fetch_array($sqlCourses)){
                                ?>
                            <option value="<?=$resCourses["id"]?>" <?=$_REQUEST['course_id'] == $resCourses ["id"] ? 'selected=selected' : '' ?> ><?=$resCourses["batch_code"]?></option>
                            <?php		
                            }
                            ?>
                        </select>
                    </td>
                </tr>
                <?php
                  	if($_REQUEST['course_id'] == '')
					{
				  ?>
                  <tr style="background: #D9D9FD " height="25">
                 	<td colspan="2"><div align="left" class="successMsg" id="err_site" style="display:block">
                       &nbsp; <strong><?=('Select your course please for checking details.')?></strong>
                    </div></td>
                  </tr>
                  <?php
				    exit();
                  	}
				 ?> 
                <tr height="30">
                    <td width="249" align="left" style="padding-left:15px">User Course</td>
                    <td width="466" align="left">
                    	<?=($resCourseData["category"])?>                       
                    </td>
                </tr> 
                 <tr height="30">
                    <td width="249" align="left" style="padding-left:15px">Course Code</td>
                    <td width="466" align="left">
                     <?=$resCourseData["batch_code"]?>                   </td>
                </tr>
                <tr height="30">
                    <td width="249" align="left" style="padding-left:15px"> Course Start Date</td>
                    <td width="466" align="left">
                       <?=($resCourseData["start_date"] != '' ? $resCourseData["start_date"] : '')?></td>
                </tr>
				<tr height="30">
                    <td width="249" align="left" style="padding-left:15px">Course End Date</td>
                    <td width="466" align="left">
                     	<?=($resCourseData["end_date"] != '' ? $resCourseData["end_date"] : '')?></td>
                  </tr>
              
                   <tr height="30">
                    <td width="249" align="left" style="padding-left:15px">Number of classes</td>
                    <td width="466" align="left">
                   	<?=($resCourseData["number_classes"])?>
                    </select>
                    </td>
                  </tr>
              	<tr height="30">
                    <td width="249" align="left" style="padding-left:15px">Course Comments</td>
                    <td width="466" align="left">
                      <?=nl2br($resCourseData["comments"])?>                  </td>
                  </tr>
                  <tr  height="30">
                    <td width="249" align="left" style="padding-left:15px">Active</td>
                    <td width="466" align="left">
                    		<?=('N' == $resCourseData['active'] ? 'Not' : 'Yes')?>
                        </select>                    </td>
                  </tr>
                  <tr>
                  	<td colspan="2" align="center">
                    	<table width="600" style="border:1px solid #000" >
                        	<tr style=" background:#000;color:#FFF; font-weight:bold">
                            <td style="color:#FFF" width="5%">&nbsp;</td>
                            	<td style="color:#FFF" colspan="5">Course Schedule</td>
                               
                            </tr>
                            <tr style=" background:#A1A1A1;color:#FFF; font-weight:bold">
                            <td style="color:#FFF" width="5%">&nbsp;</td>
                            	<td style="color:#FFF" width="30%">Class</td>
                                <td style="color:#FFF">Start Time</td>
                                <td style="color:#FFF">End Time</td>
                                <td></td>
                            </tr>
                            <?php
							 $numberClasses = $resCourseData["number_classes"];
							 $sqlScheduleClass = mysql_query("SELECT * FROM software_schedule_class  where course = '".$resCourseData["batch_code"]."'");
							 while($resScheduleClass = mysql_fetch_array($sqlScheduleClass)){
								 $showClasses = 1;
								 $arrCourseClass[$resScheduleClass["course_class"]]['start_date'] = $resScheduleClass["start_time"];
								 $arrCourseClass[$resScheduleClass["course_class"]]['end_date']   = $resScheduleClass["end_time"];
								 
							 }
							if($showClasses)
							{							
                            	for($i=1;$i<=$numberClasses;$i++)
								{
									if($x%2) $bgColor = 'bgcolor = "#FFFFFF"'; else $bgColor = 'bgcolor = "#F0F0F0"';
										 $x++;
							?>
                            <tr <?=$bgColor?> height="25"  >
                            	<td style="color:#FFF" width="5%">&nbsp;</td>
                                <td >Class<?=$i?></td>
                                <td ><?=($arrCourseClass[$i]["start_date"] == '' ? 'NA' : $arrCourseClass[$i]["start_date"])?></td>
                                <td><?=($arrCourseClass[$i]["end_date"] == '' ? 'NA' : $arrCourseClass[$i]["end_date"])?></td>
                                <td></td>
                            </tr>
                           <?php
								}
							}if(!$showClasses){
							?>
                            <tr  style="background: #FFE9E9" >	
                            	<td  width="5%">&nbsp;</td>
                                <td colspan="5" style="color:#CA0000" >No,classes scheduled</td>
                           </tr>
                            <?php
							}
							?>
							
						</table>
                    
                    </td>
                  </tr>
                   
                  <tr>
                  	<td colspan="2" >&nbsp;</td>
                  </tr>
                  <tr>
                  	<td colspan="2" align="center">
                    	<table width="600" style="border:1px solid #000" >
                        	<tr style=" background:#000;color:#FFF; font-weight:bold">
                            <td style="color:#FFF" width="5%">&nbsp;</td>
                            	<td style="color:#FFF" colspan="5">Trainer</td>
                            </tr>
                             <tr>
                           		<td style="color:#000" width="5%">&nbsp;</td>
                            	<td style="color:#000;font-weight:bold" >Trainer Name</td>
                                <td style="color:#000" ><?=($resCourseData["first_name"] == '' ? 'NA' :$resCourseData["first_name"] )?></td>
                                <td style="color:#000;font-weight:bold">Trainer Email</td>
                                <td style="color:#000" colspan="2"><?=($resCourseData["email"] == '' ? 'NA' :$resCourseData["email"] )?></td>
                            </tr>
                           
                       <tr style=" background:#000;color:#FFF; font-weight:bold">
                            <td style="color:#FFF" width="5%">&nbsp;</td>
                            	<td style="color:#FFF" colspan="5">Students</td>
                               
                            </tr>
                            <tr style=" background:#A1A1A1;color:#FFF; font-weight:bold">
                            <td style="color:#FFF" width="5%">&nbsp;</td>
                            	<td style="color:#FFF" > First Name</td>
                                <td style="color:#FFF" > Last Name</td>
                                <td style="color:#FFF">Email</td>
                                <td style="color:#FFF">Mobile</td>
                                <td style="color:#FFF">Address</td>
                           </tr>
                            <?php
							$sqlStdClass = mysql_query("SELECT first_name,email,last_name,mobile,address FROM software_users_courses_assign as SCU 
  																	INNER JOIN software_user AS SU ON 
																			SCU.user_id = SU.Id
																WHERE courses_id = '".$resCourseData['batch_code']."' AND user_course_type = 'Student'");
							 while($resStdClass = mysql_fetch_array($sqlStdClass)){
								 $recordCls = true;
							?>
							<tr>	
                                <td  width="5%">&nbsp;</td>
                            	<td style="color:#000" ><?=$resStdClass["first_name"]?></td>
                                <td style="color:#000"><?=$resStdClass["last_name"]?></td>
                                <td style="color:#000"><?=$resStdClass["email"]?></td>
                                <td style="color:#000"><?=$resStdClass["mobile"]?></td>
                                <td style="color:#000"><?=$resStdClass["address"]?></td>
                           </tr>
							<?php	
							 }
							if(!$recordCls){
							?>
                            <tr  style="background: #FFE9E9" >	
                            	<td  width="5%">&nbsp;</td>
                                <td colspan="5" style="color:#CA0000" >No,studend roled</td>
                           </tr>
                            <?php
							}
							?>
                             
                          </table>
                    
                    </td>
                  </tr>
                  <tr>
                  				<td colspan="2" >&nbsp;</td>
                  			</tr>
                </table>
			    <ul class="site_nav_menu_buttons">
			      <li class="no_menu_li"><span><a href="courses.php">&nbsp;Back to Courses </a></span></li>
			      </ul>
			    <p>&nbsp;</p>
			  </form>			  </td>
            </tr>
	        </table></td>
        </tr>
      <tr bgcolor="#FAFAFA">
        <td width="800" align="center" valign="top">&nbsp;</td>
        <td width="100" colspan="2">&nbsp;</td>
      </tr>
	    <tr bgcolor="#FAFAFA">
        <td width="800" align="center" valign="top">&nbsp;</td>
        <td colspan="2">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>

